package com.st.entity;

import lombok.Data;
import lombok.NoArgsConstructor;

import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Data
@NoArgsConstructor
public class Goods {
    private Integer id;
    private String goodsName;
    private String imgUrl;
    private BigDecimal goodsPrice;
    private Integer goodsCount;
    private Integer goodsStatus;//商品状态1-上架，0-下架 默认下架
    private Integer superiorId;
    private Timestamp createTime;//操纵商品时间
    //分类的名字
    private String categoryName;
    private Integer pageNum;//页码
    private Integer pageSize; //单页展示行数

    public Map<String,String> toHash(){
        Map<String,String> map=new HashMap<>();
        map.put("id",id.toString());
        map.put("goodsName",goodsName);
        map.put("imgUrl",imgUrl == null? "" :imgUrl);
        map.put("goodsPrice",goodsPrice.toString());
        map.put("goodsCount",goodsCount.toString());
          return map;
    }
    public void getValue(List<String> list){
        for(int i=0;i<5;i++){
            if (i==0)this.id=Integer.parseInt(list.get(i));
            if (i==1)this.goodsName=list.get(i);
            if (i==2)this.imgUrl=list.get(i);
            if (i==3)this.goodsPrice=new BigDecimal(list.get(i));
            if (i==4)this.goodsCount=Integer.parseInt(list.get(i));
        }

    }

   public  Goods (Integer id){
        this.id=id;
  }
}
